package com.inkyi.assistant.app.tools.base;

import javax.swing.*;
import java.awt.*;
import java.util.Optional;

public class InkToolsCellRenderer extends DefaultListCellRenderer {

    @Override
    public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

        String name = ((InkTools) value).getToolName();
        int sep = name.indexOf('/');
        if (sep >= 0)
            name = name.substring(sep + 1).trim();

        JComponent c = (JComponent) super.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus);
        c.setToolTipText(buildToolTip((InkTools) value));
        return c;
    }

    private String buildToolTip(InkTools ti) {
        return ti.getToolName();
    }


}
